import {messages} from "share/common";
import React from 'react'
import { connect } from 'react-redux'
import { Tabs, Button } from 'antd'
const TabPane = Tabs.TabPane;
import 'styles/credit/credit-view/credit-view.scss'
import ReimbursementCredit from 'containers/credit/credit-view/reimbursement-credit'
import ApproveCredit from 'containers/credit/credit-view/approve-credit'

class CreditView extends React.Component{
  constructor(props) {
    super(props);
    this.state = {
      tabs: [
        {key: 'reimbursement', name: messages('credit.key1')/*报销信用*/, component: <ReimbursementCredit/>},
        // {key: 'approve', name: '审批信用', component: <ApproveCredit/>}
      ],
      nowTab: 'reimbursement'
    }
  }

  componentWillMount(){}

  render() {
    const { tabs, nowTab } = this.state;
    return (
      <div className="background-transparent credit-view">
        <div className="tabs-info">
          <Tabs onChange={key => this.setState({ nowTab: key })} type="card">
            {tabs.map(tab => <TabPane tab={tab.name} key={tab.key}/>)}
          </Tabs>
        </div>
        {tabs.find(tab => tab.key === nowTab).component}
      </div>
    )
  }
}

CreditView.contextTypes = {
  router: React.PropTypes.object
};

function mapStateToProps(state) {
  return {
    company: state.login.company
  }
}

export default connect(mapStateToProps)(CreditView)
